//
//  ImagePreviewVC.swift
//  Drop
//
//  Created by zhuxuhong on 2018/3/17.
//  Copyright © 2018年 zhuxuhong. All rights reserved.
//

import UIKit

class ImagePreviewCell: UICollectionViewCell {
	@IBOutlet weak var imageView: UIImageView!
	
}

class ImagePreviewVC: UIViewController {
	@IBOutlet weak var collectionView: UICollectionView!

	fileprivate var images: [String] = ["", ""]
	
    override var preferredStatusBarStyle: UIStatusBarStyle{
        return .lightContent
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()

        setNavigationBar(isHidden: true)
        automaticallyAdjustsScrollViewInsets = false
    }
	
	override func viewWillAppear(_ animated: Bool) {
		super.viewWillAppear(animated)
		
		navigationController?.hidesBarsOnTap = true
	}
	
	override func viewWillDisappear(_ animated: Bool) {
		super.viewWillDisappear(animated)
		
		navigationController?.hidesBarsOnTap = false
	}
}

extension ImagePreviewVC: UIScrollViewDelegate{
    func scrollViewDidScroll(_ scrollView: UIScrollView) {
        setNavigationBar(isHidden: true)
    }
}

extension ImagePreviewVC: UICollectionViewDelegate, UICollectionViewDelegateFlowLayout{
	func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
		return view.bounds.size
	}
}

extension ImagePreviewVC: UICollectionViewDataSource{
	func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
		return images.count
	}
	
	func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
		let cell = collectionView.dequeueCell(withClass: ImagePreviewCell.self, for: indexPath)!
		
//		cell.imageView.image = UIImage.named(images[indexPath.row])
		
		return cell
	}
}
